﻿$(document).ready(function () {
    $(".hidden").hide();
    $(".hidden_new").hide();
    $(".showInfor_RoomType").click(function () {
        $("#info_" + $(this).attr("id")).toggle("slow");
    })

    $("#btn_add_room").click(function () {
        $("#info_new").toggle("slow");
    })

    $(".update").live("click", function () {
        var maHang = $(this).attr("id");
        var moTa = $("#moTa" + maHang).val();
        var soLuong = $("#soLuong" + maHang).val();
        var tenHang = $("#tenHang" + maHang).val();
        var dataString = "moTa=" + moTa + "&maHang=" + maHang + "&tenHang=" + tenHang
        $.ajax({
            type: "GET",
            url: "Update_RoomClass",
            data: dataString,
            dataType: 'html',
            success: function (data) {
                $("#notice" + maHang).html(data).hide().fadeIn();
                setTimeout(function () {
                    $("#notice" + maHang).fadeOut("slow", function () {
                        //$("#notice" + maLoai).remove();
                    });
                }, 2000);
            }
        });
    });


    $(".delete").live("click", function () {
        var maHang = $(this).attr("id");
        var dataString = "maHang" + maHang;
        maHang = maHang.substr(1);
        $.ajax({
            type: "GET",
            url: "Delete_RoomClass",
            data: dataString,
            dataType: 'html',
            success: function (data) {
                $("#notice_" + maHang).html(data).show();
                setTimeout(function () {
                    $("#notice_" + maHang).fadeOut("slow", function () {
                        //$("#notice" + maLoai).remove();
                    });
                }, 2000);
                location.reload();
            }
        });
    });



    $(".add").live("click", function () {
        var maHang = "_new";
        var moTa = $("#moTa" + maHang).val();
        var tenHang = $("#tenHang" + maHang).val();
        var dataString = "moTa=" + moTa  + "&tenHang=" + tenHang
        $.ajax({
            type: "GET",
            url: "Add_RoomClass",
            data: dataString,
            dataType: 'html',
            success: function (data) {
                $("#notice" + maHang).html(data).show()
                setTimeout(function () {
                    $("#notice" + maHang).fadeOut("slow", function () {
                        //$("#notice" + maLoai).remove();
                    });
                }, 2000);
                location.reload();
            }
        });
    });


});